<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let n,m,c
    let arr = [[4, 1,2,3,4],
               [2, 4,5],
               [3, 1,2,3],
               [1, 2],
               [2, 3,5]];
    // let line;
    // while ((line = read_line()) != "") {
    //     arr.push(line.split(' ').map(v=>parseInt(v)));
    // }
    n = 5
    m = 3
    c = 5

    let map = new Map()
    // 循环n个串珠
    for(let i=0; i<n; i++){
      console.log("//n")
      console.log("----循环"+i+"个串珠")

      // 循环m
      //初始化都为0
      let arr2 = Array(c+1).fill(0)
      for(let j=0; j<m;j++){
        console.log("--循环"+j)
        let cur = i+j
        if(cur>=arr.length){  // 首尾相接部分
          cur = cur - arr.length
        }
        
        for(let x=1; x<=arr[cur][0];x++){
              let curColor = arr[cur][x]
              console.log("当前颜色"+curColor)
              arr2[curColor] +=1
              console.log("当前记录"+arr2)
              if(arr2[curColor] >= 2){
                // 每次循环 arr2中大于m的记录下来
                map.set(curColor,1)
                console.log("超过了"+curColor)

              }
          }
      }
    }
    console.log(map.size)
  </script>
</body>
</html>